﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace yule.Mvc
{

    /// <summary>
    /// Mvc路径
    /// </summary>
    public class MvcPath
    {
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="rd"></param>
        public MvcPath(System.Web.Routing.RouteData rd)
        {
            object oArea = rd.Values["area"];
            object oController = rd.Values["controller"];
            object oAction = rd.Values["action"];

            this.Area = oArea == null ? null : oArea.ToString();
            this.Controller = oController == null ? null : oController.ToString();
            this.Action = oAction == null ? null : oAction.ToString();
        }

        /// <summary>
        /// 区域
        /// </summary>
        public string Area { get; set; }
        /// <summary>
        /// 控制器
        /// </summary>
        public string Controller { get; set; }
        /// <summary>
        /// 方法
        /// </summary>
        public string Action { get; set; }


        private static string _ResourcePath = null;
        /// <summary>
        /// 资源地址
        /// </summary>
        public static string ResourcePath
        {
            get
            {
                if (MvcPath._ResourcePath == null)
                {
                    MvcPath._ResourcePath = yule.Util.AppSettings.GetAppSetting(yule.Const.AppSettings.ResourcePath);
                }
                return MvcPath._ResourcePath;
            }
        }

    }
}
